import _fetch from './request'
function getTechnic ({ start, limit, q }) {
  return _fetch({
    url: '/articles/technic',
    method: 'get',
    needToken: true,
    params: {
      start,
      limit,
      q
    }
  })
}
function getHotData () {
  return _fetch({
    url: '/chart-data/hot'
  })
}
function getShare ({ start, limit, q }) {
  return _fetch({
    url: '/articles/share',
    params: {
      start,
      limit,
      q
    }
  })
}

function getSearch () {
  return _fetch({
    url: '/articles/shareTopSearch'
  })
}

function getDetail (id) {
  return _fetch({
    url: `/articles/share/${id}`
  })
}
function getComment ({ id, limit, start }) {
  return _fetch({
    url: `/articles/comments/${id}`,
    method: 'get',
    params: {
      limit,
      start
    }
  })
}
function sendComment ({ content, article, parent }) {
  return _fetch({
    url: '/articles/comments',
    method: 'post',
    data: {
      content,
      article,
      parent
    },
    needToken: true
  })
}
function getCollect ({ id }) {
  return _fetch({
    url: '/articles/collect',
    method: 'post',
    data: {
      id
    },
    needToken: true
  })
}
function getStar ({ article }) {
  return _fetch({
    url: '/articles/star',
    method: 'post',
    data: {
      article
    },
    needToken: true
  })
}
export {
  getTechnic,
  getHotData,
  getShare,
  getSearch,
  getDetail,
  getComment,
  sendComment,
  getCollect,
  getStar
}
